package com.threadDemo;

import java.util.concurrent.CountDownLatch;

public class Consumer implements Runnable{
    private final BoundedBuffer bb;
    private final CountDownLatch countDownLatch;

    Consumer(BoundedBuffer bb, CountDownLatch countDownLatch){
        this.bb = bb;
        this.countDownLatch = countDownLatch;
    }
    @Override
    public void run() {
        try {
            Object take = bb.take();
            System.out.println("开始消费数据="+take);
            countDownLatch.countDown();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
